package com.zhongjianjian.zookeeper;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

/**
 * @类名: com.zhongjianjian.zookeeper
 * @作者: lgt
 * @创建时间: 2020-02-27 15:47
 * @描述:
 **/
public class MyWatcher implements Watcher {
    @Override
    public void process(WatchedEvent watchedEvent) {

        String path = watchedEvent.getPath();  //当前放生数据变更的目录

        if (watchedEvent.getType().getIntValue()==Event.EventType.None.getIntValue()){
            System.out.println(path="======NONE=====可以做一些业务操作===");
        }else if (watchedEvent.getType().hashCode()==Event.EventType.NodeCreated.getIntValue()){
            System.out.println(path="======NodeCreated=====可以做一些业务操作===");
        }else if (watchedEvent.getType().hashCode()==Event.EventType.NodeDeleted.getIntValue()){
            System.out.println(path="======NodeDeleted=====可以做一些业务操作===");
        }else if (watchedEvent.getType().hashCode()==Event.EventType.NodeDataChanged.getIntValue()){
            System.out.println(path="======NodeDataChanged=====可以做一些业务操作===");
        }else if (watchedEvent.getType().hashCode()==Event.EventType.NodeChildrenChanged.getIntValue()){
            System.out.println(path="======NodeChildrenChanged=====可以做一些业务操作===");
        }
    }
}
